package com.example.testdemo

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.example.testdemo.eventbus.queue.BeanPostQueue
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
    var beanPostQueue = BeanPostQueue()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)


        addButton.setOnClickListener {
//            var intent =  Intent()
            val intent = Intent(this, MainActivity2::class.java)
            startActivity(intent)

//            beanPostQueue.enqueue(BeanPost.obtainBeanPost(Bean("Bean1")))
//            beanPostQueue.enqueue(BeanPost.obtainBeanPost(Bean("Bean2")))
//            beanPostQueue.enqueue(BeanPost.obtainBeanPost(Bean("Bean3")))
//            beanPostQueue.enqueue(BeanPost.obtainBeanPost(Bean("Bean4")))
//            beanPostQueue.enqueue(BeanPost.obtainBeanPost(Bean("Bean5")))
        }
        removeButton.setOnClickListener {
            var b1 = beanPostQueue.poll()
            Log.i(TAG,b1?.bean!!.name)
            var b2 = beanPostQueue.poll()
            Log.i(TAG,b2?.bean!!.name)
            var b3 = beanPostQueue.poll()
            Log.i(TAG,b3?.bean!!.name)
            var b4 = beanPostQueue.poll()
            Log.i(TAG,b4?.bean!!.name)
            var b5 = beanPostQueue.poll()
            Log.i(TAG,b5?.bean!!.name)
        }
    }

    companion object {
        private const val TAG = "MainActivity"
    }

}
